package com.xzp.cmn.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xzp.cmn.mapper.DictMapper;
import com.xzp.yygh.model.cmn.Dict;
import com.xzp.yygh.vo.cmn.DictEeVo;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class DictListener extends AnalysisEventListener<DictEeVo>  {

    private final DictMapper dictMapper;

    public DictListener(DictMapper dictMapper){
        this.dictMapper = dictMapper;
    }

    @Override
    public void invoke(DictEeVo dictEeVo, AnalysisContext analysisContext) {
        Dict dict = new Dict();
//        System.out.println(dictEeVo);
        BeanUtils.copyProperties(dictEeVo, dict, Dict.class);
        // 设置数据为未被删除状态，否则显示不出来
        dict.setIsDeleted(0);
        dictMapper.insert(dict);
    }



    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}



